package utils

import (
	"errors"
	"time"
)

// RSA 1024 PKCS1
const publicKey = `-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEA2ErzCs2FbvLQznnBLgPHScbHABW8sxw3l60mwnNG1VR7ANt6ia2s
GpZK3zYB8ShsraMfuImx5zC9y+D8hNH7csrtYuALtLHGY+5rfZEEKv0hyLZwDeCB
EwRfZi07hJT4dqnp3cndOyCAWsGOxqBuLYlo4rjOTYEQA5O5x35IZqhk1I3wtKYr
+yWtMs/1kh1MUxSarQxsKisvKaJ+cGHc2vnM2TreW7JgM/s2Q4gDGMFMbWWtWWlK
mPs3Sd/4/RM/a+9mkZDFI4CqojZ1q3BzBjfZmdjiZcY/5sOBEGgKtup0t7xetvE+
Jo2kXScdbkpsG1ZiL6T+qJf9z0CXVVzDOQIDAQAB
-----END RSA PUBLIC KEY-----
`

const privateKey = `-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA2ErzCs2FbvLQznnBLgPHScbHABW8sxw3l60mwnNG1VR7ANt6
ia2sGpZK3zYB8ShsraMfuImx5zC9y+D8hNH7csrtYuALtLHGY+5rfZEEKv0hyLZw
DeCBEwRfZi07hJT4dqnp3cndOyCAWsGOxqBuLYlo4rjOTYEQA5O5x35IZqhk1I3w
tKYr+yWtMs/1kh1MUxSarQxsKisvKaJ+cGHc2vnM2TreW7JgM/s2Q4gDGMFMbWWt
WWlKmPs3Sd/4/RM/a+9mkZDFI4CqojZ1q3BzBjfZmdjiZcY/5sOBEGgKtup0t7xe
tvE+Jo2kXScdbkpsG1ZiL6T+qJf9z0CXVVzDOQIDAQABAoIBAQCQInoN8+F8ixE8
1wQ1/syaTH2mf9XM4fvl9rxCjoFgfjit3JSvFO4AlbD1SE9I/rBVkcP8vL2yG9gO
+jIs7KWM3NAOuND0LBfR1jsJZU8Kur79ux23EanSG3Lbaz8jXgapRReU9gWYdlMy
p5PWp2hkrhIYLCFGosAiMhp2Z6Alz84YQCxdhJYzPJTB7P1Jdt6yadREOtV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Second * 24 * 60 * 60 * 1 // 1day
	RefreshTokenExpired = 2 * TokenExpired               // 2 * te
)

var (
	ErrInvalidToken = errors.New("invalid token")
	ErrExpiredToken = errors.New("token has expired")
	ErrTokenAuthErr = errors.New("token authentication failure")
)

type GenerateParam struct {
	UserID   int64  `json:"userId"`
	Name     string `json:"name"`
	Status   int8   `json:"status"`
	UserType int64  `json:"userType"`
}

type NewJWTManagerParam struct {
	SecretKey            string        `json:"secretKey"`
	PubKey               string        `json:"pubKey"`
	TokenDuration        time.Duration `json:"tokenDuration"`
	RefreshTokenDuration time.Duration `json:"refreshTokenDuration"`
}
